import axios from 'axios'
const qs=require('qs')

export function getUser() {
    const url='/api/users';
    return axios.post(url).then((res)=>{
        return Promise.resolve(res)
    })
}

// 登录
export function login(data) {
    const url ='/api/login';
    return axios.post(url,qs.stringify(data)).then((res)=>{
        return Promise.resolve(res)
    })
}


// 登录退出
export function logout() {
    const url='/api/logout';
    return axios.get(url).then(res=>{
        return Promise.resolve(res)
    })
}
// 买书
export function buyBook() {
    const url='/api/buy'
    return axios.get(url).then(res=>{
        return Promise.resolve(res)
    })
}

export function getBooks() {
    return axios.get('static/mock/initBooks.json').then(res=>{
        return Promise.resolve(res)
    })
}